﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace HouseKeepingPL.HKService
{
    public partial class Income : IDataErrorInfo
    {
        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        public string this[string columnName]
        {
            get
            {
                string result = null;
                if (columnName == "Date")
                {
                    if (Date < DateTime.Now.AddYears(-100))
                    {
                        result = "A 100 years old action is impossible";
                    }
                }

                if (columnName == "Amount")
                {
                    if (Amount <= 0)
                    {
                        result = "Amount must be positive number";
                    }
                    else
                    {
                        if (Amount >= Decimal.MaxValue)
                        {
                            result = Decimal.MaxValue + " is the maximum value allowed!";
                        }
                    }
                }

                if (columnName == "Comment")
                {
                    if (string.IsNullOrWhiteSpace(Comment))
                    {
                        result = "Comment must not left empty!";
                    }
                    else
                    {
                        if (Comment.Length > 4000)
                        {
                            result = "Comment is too large! ";
                        }
                    }
                }

                if (columnName == "ActionTypeId")
                {
                    if (ActionTypeId < 1)
                    {
                        result = "Action type must have positive non-zero id";
                    }
                }


                return result;
            }
        }
    }
}
